package com.staticstep.demo;

import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.core.fs.FSDataInputStream;
import org.apache.flink.core.fs.FileSystem;
import org.apache.flink.core.fs.Path;
import org.apache.flink.core.fs.local.LocalFileSystem;
import org.apache.flink.streaming.api.datastream.KeyedStream;
import org.apache.flink.streaming.api.datastream.WindowedStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows;
import org.apache.flink.streaming.api.windowing.assigners.WindowAssigner;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;

import java.io.File;
import java.io.IOException;
import java.time.Duration;

public class WordCountBatchDemo {
    public static void main(String[] args) throws IOException {
        // todo 1 创建执行环境
        StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();

        // todo 2 读取数据：从文件中读取

        KeyedStream<String, Tuple> keyedStream = environment.readTextFile().keyBy();
        FileSystem localFileSystem = FileSystem.getLocalFileSystem();
        FSDataInputStream open = localFileSystem.open(new Path("input/word.txt"));

        WindowedStream<String, Tuple, TimeWindow> window = keyedStream.window(TumblingProcessingTimeWindows.of(Duration.of(15L)));

        


        // todo 3
    }
}
